package com.cap.bts.crmdp.webservice.mars.client;

import java.io.UnsupportedEncodingException;
import java.rmi.RemoteException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.net.ssl.HostnameVerifier;
import javax.net.ssl.HttpsURLConnection;
import javax.net.ssl.SSLSession;

import org.apache.axis2.AxisFault;
import org.apache.axis2.client.Options;
import org.apache.axis2.client.ServiceClient;
import org.apache.axis2.transport.http.HTTPConstants;
import org.apache.axis2.transport.http.HttpTransportProperties;
import org.apache.commons.lang3.StringEscapeUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.log4j.Logger;
import org.dom4j.Document;
import org.dom4j.DocumentException;
import org.dom4j.DocumentHelper;
import org.dom4j.Element;
import org.dom4j.Node;

import com.alibaba.fastjson.JSON;
import com.cap.bts.crmdp.dealer.dealerinfosync.domain.DealerInfoRelMars;
import com.cap.bts.crmdp.dealer.dealerinfosync.service.IDealerInfoSyncService;
import com.cap.bts.crmdp.dealer.mars.domain.MarsConfig;
import com.cap.bts.crmdp.dealer.mars.domain.MarsLog;
import com.cap.bts.crmdp.dealer.mars.dto.CouponRedeemtionDto;
import com.cap.bts.crmdp.dealer.mars.dto.ItemForCouponDto;
import com.cap.bts.crmdp.dealer.mars.dto.ItemTypeInfoDto;
import com.cap.bts.crmdp.dealer.mars.dto.MarsEligibilityDto;
import com.cap.bts.crmdp.dealer.mars.dto.MarsEligibilityLineDto;
import com.cap.bts.crmdp.dealer.mars.service.IMarsConfigService;
import com.cap.bts.crmdp.dealer.mars.util.Base64Util;
import com.cap.bts.crmdp.mars.util.LogTask;
import com.cap.bts.crmdp.mars.util.ThreadPoolUtil;
import com.cap.bts.crmdp.mars.util.URLEncoderUtil;
import com.cap.bts.crmdp.webservice.WSCrmFacade;
import com.cap.bts.crmdp.webservice.dto.CardDto;
import com.cap.bts.crmdp.webservice.dto.CouponDto;
import com.cap.bts.crmdp.webservice.dto.CouponItemDto;
import com.cap.bts.crmdp.webservice.dto.MarsResultDto;
import com.cap.bts.crmdp.webservice.dto.MarsSellPackageDto;
import com.cap.bts.crmdp.webservice.dto.WSCrmActivationResultDto;
import com.cap.bts.crmdp.webservice.dto.WSCrmRedemptionResultDto;
import com.cap.bts.crmdp.webservice.mars.client.util.AADConfiguration;
import com.cap.bts.crmdp.webservice.mars.client.util.TokenUtil;
import com.cap.bts.framework.common.util.ApplicationContextUtil;
import com.microsoft.aad.adal4j.AuthenticationResult;

/**
 * 
 * @author annson
 *
 */
public class CRM2MARS {
	private static final Logger LOGGER = Logger.getLogger(WSCrmFacade.class);

	
	/**
	 * 激活
	 * @param dto
	 * @return
	 */
	public MarsResultDto activation(WSCrmActivationResultDto dto) {
		
		StringBuilder xmlBuilder = new StringBuilder();
		
		xmlBuilder.append("<?xml version=\"1.0\" encoding=\"UTF-8\"?><root><method>MARSACTIVATION</method>");
//		xmlBuilder.append("<soNumber>").append(dto.getSoNumber()).append("</soNumber>");
		xmlBuilder.append("<custNo>").append(dto.getCustNo()).append("</custNo>");
		xmlBuilder.append("<custStatus>").append(dto.getCustStatus()).append("</custStatus>");
		xmlBuilder.append("<preCustNo>");
		if(StringUtils.isNotBlank(dto.getPreCustNo()) && !dto.getPreCustNo().equals(dto.getCustNo())){
			xmlBuilder.append(dto.getPreCustNo());
		}
		xmlBuilder.append("</preCustNo>");
		
		xmlBuilder.append("<vehicleNo>").append(dto.getVehicleNo()).append("</vehicleNo>");
		xmlBuilder.append("<vehicleStatus>").append(dto.getVehicleStatus()).append("</vehicleStatus>");
		
		
		xmlBuilder.append("<preVehicleNo>");
		if(StringUtils.isNotBlank(dto.getPreVehicleNo()) && !dto.getPreVehicleNo().equals(dto.getVehicleNo())){
			xmlBuilder.append(dto.getPreVehicleNo());
		}
		xmlBuilder.append("</preVehicleNo>");
		
		
		xmlBuilder.append("<serviceCenter>").append(dto.getServerCenter()).append("</serviceCenter>");
		
		xmlBuilder.append("<cards>");
		for (CardDto card : dto.getCards()){
			xmlBuilder.append("<card>");
			xmlBuilder.append("<cardNo>").append(card.getCardNumber()).append("</cardNo>");
			xmlBuilder.append("<cardAmount>").append(card.getAmount()).append("</cardAmount>");
			xmlBuilder.append("</card>");
		}
		xmlBuilder.append("</cards>");
		
		xmlBuilder.append("</root>");
		
		return callMARS(Integer.valueOf(dto.getServerCenter()), xmlBuilder.toString(), "MARSACTIVATION");
		
	}
	
	
	/**
	 * 购买套餐
	 * @param marsSellPackageDto
	 * @return
	 */
	public MarsResultDto sellpackage(MarsSellPackageDto marsSellPackageDto) {
		
		StringBuilder xmlBuilder = new StringBuilder();
		
		xmlBuilder.append("<?xml version=\"1.0\" encoding=\"UTF-8\"?><root><method>MARSSELL</method>");
		xmlBuilder.append("<soNumber>").append(marsSellPackageDto.getSoNumber()).append("</soNumber>");
		xmlBuilder.append("<cardNo>").append(marsSellPackageDto.getCardNo()).append("</cardNo>");
		xmlBuilder.append("<packageName>").append(marsSellPackageDto.getPackageName()).append("</packageName>");
		xmlBuilder.append("<businessType>").append(marsSellPackageDto.getBusinessType()).append("</businessType>");
		xmlBuilder.append("<amount>").append(marsSellPackageDto.getAmount()).append("</amount>");
		xmlBuilder.append("<activation>").append(marsSellPackageDto.getActivation()).append("</activation>");
		xmlBuilder.append("</root>");
		
		return callMARS(marsSellPackageDto.getDealerId().intValue(), xmlBuilder.toString(), "MARSSELL");
		
	}
	
	
	/**
	 * MARS Item Filter
	 * @param dto
	 * @return
	 */
	public MarsResultDto itemEligibility(MarsEligibilityDto dto) {
        
        StringBuilder xmlBuilder = new StringBuilder();
        
        xmlBuilder.append("<?xml version=\"1.0\" encoding=\"UTF-8\"?><root><method>MARSITEMELIGIBILITY</method>");
        xmlBuilder.append("<categoryType>").append(dto.getCategoryType()).append("</categoryType>");
        xmlBuilder.append("<categoryValue>").append(dto.getCategoryValue()).append("</categoryValue>");
        xmlBuilder.append("<serviceCenter>").append(dto.getServerCenter()).append("</serviceCenter>");
        if(dto.getItemFamily()!=null){
            xmlBuilder.append("<itemFamily>").append(dto.getItemFamily()).append("</itemFamily>");
        }else{
            xmlBuilder.append("<itemFamily>").append("</itemFamily>");
        }
        xmlBuilder.append("<criterias>");
        for(MarsEligibilityLineDto eligibilityLineDto : dto.getCriterias()){
        	xmlBuilder.append("<criteria>");
        	xmlBuilder.append("<attribute>").append(eligibilityLineDto.getAttribute()).append("</attribute>");
        	xmlBuilder.append("<operator>").append(eligibilityLineDto.getOperator()).append("</operator>");
        	xmlBuilder.append("<attrValue>").append(eligibilityLineDto.getAttrValue()).append("</attrValue>");
            xmlBuilder.append("</criteria>");
        }
        
        xmlBuilder.append("</criterias>");
        
        xmlBuilder.append("</root>");
        MarsResultDto resultDto = callMARS(Integer.valueOf(dto.getServerCenter()), xmlBuilder.toString(), "MARSITEMELIGIBILITY");
        
        if(resultDto.getSuccessFlag()){
        	Document document = resultDto.getDocument();
        	Element rootElement = document.getRootElement();
        	
        	
        	List<Node> itemNodes = rootElement.selectNodes("items/item");
        	if(itemNodes != null && !itemNodes.isEmpty()){
        		for(Node node : itemNodes){
        			ItemTypeInfoDto tmp = new ItemTypeInfoDto();
        			tmp.setItemSource(1);
        			
        			tmp.setItemCode(getNodeValue(node, "itemCode"));
        			tmp.setDescription1(getNodeValue(node, "description"));
        			tmp.setDescription2(getNodeValue(node, "description2"));
        			tmp.setInventory(getNodeValue(node, "balance"));
        			String itemSource = getNodeValue(node, "centralMaintenance");
        			Integer source = Integer.valueOf(itemSource);
        			tmp.setItemSource(source == 1 ? 0 : 1);
        			
        			resultDto.getItemList().add(tmp);
        		}
        	}
        	
        }
        
		
        
        
        return resultDto;
   
	}
	
	
	/**
	 * get MARS Item inventory
	 * @param dto
	 * @return
	 */
	public void getItemInventory(List<ItemTypeInfoDto> list, String serverCenter) {
        
        StringBuilder xmlBuilder = new StringBuilder();
        
        xmlBuilder.append("<?xml version=\"1.0\" encoding=\"UTF-8\"?><root><method>MARSITEMBALANCE</method>");
        xmlBuilder.append("<serviceCenter>").append(serverCenter).append("</serviceCenter>");
        xmlBuilder.append("<items>");
        boolean hasWecareFlag = false;
        for(ItemTypeInfoDto itemDto : list){
        	if(0 == itemDto.getItemSource()){
        		hasWecareFlag = true;
        		xmlBuilder.append("<itemCode>").append(StringEscapeUtils.escapeXml10(itemDto.getItemCode())).append("</itemCode>");
        	}
        }
        if(hasWecareFlag){
        	xmlBuilder.append("</items>");        
        	xmlBuilder.append("</root>");
        	MarsResultDto resultDto = callMARS(Integer.valueOf(serverCenter), xmlBuilder.toString(), "MARSITEMBALANCE");
        	
        	if(resultDto.getSuccessFlag()){
        		Document document = resultDto.getDocument();
        		Element rootElement = document.getRootElement();
        		
        		
        		List<Node> itemNodes = rootElement.selectNodes("items/item");
        		Map<String, String> inventoryMap = new HashMap();
        		if(itemNodes != null && !itemNodes.isEmpty()){
        			for(Node node : itemNodes){
        				inventoryMap.put(getNodeValue(node, "code"), getNodeValue(node, "balance"));
        			}
        			
        			for(ItemTypeInfoDto itemDto : list){
        				if(0 == itemDto.getItemSource()){
        					itemDto.setInventory(inventoryMap.get(itemDto.getItemCode()));
        				}
        			}
        		}
        	}
        }
        
   
	}
	
	
	
	/**
	 * MARS 
	 * @param dto
	 * @return
	 */
	public MarsResultDto redeemPackageItems(WSCrmRedemptionResultDto dto) {
		
		for (int i = 0; i < dto.getCouponList().size(); i++) {
			CouponDto couponDto = dto.getCouponList().get(i);
        	if(couponDto.getItemList() == null || couponDto.getItemList().isEmpty()){
        		dto.getCouponList().remove(i);
        		i--;
        	}
		}
		if(dto.getCouponList().size() < 1){
			MarsResultDto marsResultDto = new MarsResultDto();
			
			marsResultDto.setStatusCode("1");
			marsResultDto.setResultMessage("不需要调用MARS接口。");
			
			return marsResultDto;			
		}
		
        
        StringBuilder xmlBuilder = new StringBuilder();
        
        xmlBuilder.append("<?xml version=\"1.0\" encoding=\"UTF-8\"?><root><method>MARSREDEMPTION</method>");
        xmlBuilder.append("<soNumber>").append(dto.getSoNumber()).append("</soNumber>");
        for (CouponDto couponDto : dto.getCouponList()) {
        	
        	xmlBuilder.append("<coupon>");
        	xmlBuilder.append("<couponNo>").append(couponDto.getCouponNo()).append("</couponNo>");
        	xmlBuilder.append("<couponType>").append(couponDto.getCouponType()).append("</couponType>");
        	xmlBuilder.append("<discountType>").append(couponDto.getDiscountType() != null ? couponDto.getDiscountType() : "").append("</discountType>");
        	for (CouponItemDto itemDto : couponDto.getItemList()) {
            	xmlBuilder.append("<item>");
            	xmlBuilder.append("<itemNo>").append(StringEscapeUtils.escapeXml10(itemDto.getItemNo())).append("</itemNo>");
            	xmlBuilder.append("<itemFamily>").append(StringUtils.defaultString(itemDto.getItemFamily())).append("</itemFamily>");
            	xmlBuilder.append("<itemSource>").append(itemDto.getItemSource()).append("</itemSource>");
            	xmlBuilder.append("<quantity>").append(itemDto.getQuantity()).append("</quantity>");
            	xmlBuilder.append("<price>").append(itemDto.getPrice() != null ? itemDto.getPrice() : "").append("</price>");
            	xmlBuilder.append("<discount>").append(itemDto.getDiscount() != null ? itemDto.getDiscount() : "").append("</discount>");
            	xmlBuilder.append("<actualDiscount>").append(itemDto.getActualDiscount() != null ? itemDto.getActualDiscount() : "").append("</actualDiscount>");
            	xmlBuilder.append("</item>");
    		}
        	xmlBuilder.append("</coupon>");
		}
        
        xmlBuilder.append("</root>");
        return callMARS(Integer.valueOf(dto.getServerCenter()), xmlBuilder.toString(), "MARSREDEMPTION");
   
	}
	
	
	
	
	/**
	 * MARS 
	 * @param dto
	 * @return
	 */
	public MarsResultDto redeemCoupon(CouponRedeemtionDto dto) {
		
        
        StringBuilder xmlBuilder = new StringBuilder();
        
        xmlBuilder.append("<?xml version=\"1.0\" encoding=\"UTF-8\"?><root><method>MARSCOUPONREDEMPT</method>");
        xmlBuilder.append("<soNumber>").append(dto.getSoNumber()).append("</soNumber>");
        	xmlBuilder.append("<coupon>");
        	xmlBuilder.append("<couponNo>").append(dto.getCouponNo()).append("</couponNo>");
        	xmlBuilder.append("<discountType>").append(StringUtils.defaultString(dto.getDiscountType())).append("</discountType>");
        	for (ItemForCouponDto itemDto : dto.getItemList()) {
        		itemDto.initData();
            	xmlBuilder.append("<item>");
            	xmlBuilder.append("<itemType>").append(StringUtils.defaultString(itemDto.getItemType())).append("</itemType>");
            	xmlBuilder.append("<itemNo>").append(StringEscapeUtils.escapeXml10(itemDto.getItemNo())).append("</itemNo>");
            	xmlBuilder.append("<itemSource>").append(itemDto.getItemSource()).append("</itemSource>");
            	xmlBuilder.append("<quantity>").append(itemDto.getQuantity()).append("</quantity>");
            	xmlBuilder.append("<discount>").append(itemDto.getDiscount() != null ? itemDto.getDiscount() : "").append("</discount>");
            	xmlBuilder.append("<description>").append(StringUtils.defaultString(itemDto.getDescription())).append("</description>");
            	xmlBuilder.append("</item>");
    		}
        	xmlBuilder.append("</coupon>");
        
        xmlBuilder.append("</root>");
        return callMARS(Integer.valueOf(dto.getServerCenter()), xmlBuilder.toString(), "MARSCOUPONREDEMPT");
   
	}
	
	
	private MarsResultDto callMARS(Integer dealerId, String paramXml, String method) {
		MarsResultDto marsResultDto = new MarsResultDto();
		
		MarsLog marsLog = new MarsLog("webServices");
		marsLog.setSuccessFlag("success");		
		marsLog.setCallMethod(method);	
		ServiceClient serviceClient = null;
		try {
			IDealerInfoSyncService dealerInfoSyncService = (IDealerInfoSyncService)ApplicationContextUtil.getBean("dealerInfoSyncServiceImpl");
			
			DealerInfoRelMars dealerInfoRelMars = dealerInfoSyncService.getMarsTenantByDearId(dealerId);
			
			
			IMarsConfigService marsConfigService = (IMarsConfigService)ApplicationContextUtil.getBean("marsConfigServiceImpl");
			
			MarsConfig config = marsConfigService.get();
			
			if(config == null){
				
				marsResultDto.setStatusCode("0");
				marsResultDto.setResultMessage("MARS接口相关信息未配置，请联系管理员！");
				
				
				return marsResultDto;
			}
			
			
			StringBuilder urlBuilder = new StringBuilder();
			
			
			urlBuilder.append(config.getProtocol()).append("://");
			urlBuilder.append(config.getServerDomain()).append(":").append(config.getServerPort()).append("/");
			urlBuilder.append(URLEncoderUtil.encode(config.getMarsServiceName())).append("/WS/");
			urlBuilder.append(URLEncoderUtil.encode(dealerInfoRelMars.getCompany()));
			urlBuilder.append("/Codeunit/CRM2MARS?tenant=").append(URLEncoderUtil.encode(dealerInfoRelMars.getMarsTenantId()));
			
			
			marsLog.setDescp(urlBuilder.toString());
			
			//call mars web services
//			CRM2MARSStub stub = new CRM2MARSStub(
//					"http://marsns.chinacloudapp.cn:57057/CHINACTPDEMO2/WS/MARS%20W1%20ERM%20Dealer%20123456/Codeunit/CRM2MARS?tenant=r5dealer123456");
			CRM2MARSStub stub = new CRM2MARSStub(urlBuilder.toString());

			serviceClient = stub._getServiceClient();
			Options options = serviceClient.getOptions();
			
			//http basic
			if(StringUtils.equals(config.getAuthMode(), "HTTP_BASIC")){
				HttpTransportProperties.Authenticator auth = new HttpTransportProperties.Authenticator();
				auth.setPreemptiveAuthentication(true);
//				auth.setUsername("webservice");
//				auth.setPassword("PrJmwQ+WuWoF55tmdbqEqZmghvn07yo5mxgCiPpS38w=");
				auth.setUsername(config.getUserName());
				auth.setPassword(config.getPwd());

				options.setProperty(HTTPConstants.AUTHENTICATE, auth);
				
				
			}else if(StringUtils.equals(config.getAuthMode(), "AAD")){//ad
				
				//信任所有SSL证书
				HostnameVerifier hv = new HostnameVerifier() {
		            public boolean verify(String urlHostName, SSLSession session) {
		                LOGGER.warn("Warning: URL Host: " + urlHostName + " vs. "
		                                   + session.getPeerHost());
		                return true;
		            }
		        };
		    	trustAllHttpsCertificates();
		    	HttpsURLConnection.setDefaultHostnameVerifier(hv);
		    	
		    	AADConfiguration aadConfiguration = JSON.parseObject(config.getDescp(), AADConfiguration.class);
		    	//todo config 
		    	/*aadConfiguration.setAuthority("https://login.chinacloudapi.cn/b7baf999-1be3-4c6e-a6c5-e84badfac299/oauth2/authorize");
		    	aadConfiguration.setResource("http://marsns.chinacloudapp.cn:8080/chinactpdemoaad/webclient/");
		    	aadConfiguration.setClientId("2f19aa37-1076-42df-a2a7-97f9c02ef769");
		    	aadConfiguration.setClientSecret("MNxVcrsEOPowPS/ugqNBS9FhFCHm65T8gkIyXDSU400=");
		    	aadConfiguration.setUserName("chen.ma@testfj.partner.onmschina.cn");
		    	aadConfiguration.setPassword("Mchen233");*/
		    	

		    	AuthenticationResult result = TokenUtil.getAccessTokenFromUserCredentials(aadConfiguration);
		    	LOGGER.info("Access Token - " + result.getAccessToken());
		    	LOGGER.info("Token Type - " + result.getAccessTokenType());
		    	LOGGER.info("Expire At - " + result.getExpiresOn());

				String token = result.getAccessToken();
				
				options.setProperty("Authorization", "Bearer " + token);
			}
			
			
			options.setManageSession(true);   
			options.setProperty(HTTPConstants.REUSE_HTTP_CLIENT, true); 

			CRM2MARSStub.Send info = new CRM2MARSStub.Send();
			
			String xml = Base64Util.encode(paramXml);
			
			marsLog.setParamText(paramXml);
			marsLog.setParamTextEncrypt(xml);
			
			LOGGER.info("send MARS:" + paramXml);
			LOGGER.info("send MARS(Base64):" + xml);

			info.setCRMRequest(xml);
			info.setMARSResponse("");

			CRM2MARSStub.Send_Result returnSend = stub.send(info);

			LOGGER.info("receive MARS msg(Base64):" + returnSend.getMARSResponse());
		
			Document document = null;
			
			String receiveMarsText = Base64Util.decode(returnSend.getMARSResponse());
			
			LOGGER.info("receive MARS msg:" + receiveMarsText);
			
			marsLog.setReturnTextEncrypt(" " + returnSend.getMARSResponse());
			marsLog.setReturnText(" " + receiveMarsText);
		
			document = DocumentHelper.parseText(receiveMarsText);
			Element rootElement = document.getRootElement();
			
			marsResultDto.setDocument(document);
			
			Node statusCodeNode = rootElement.selectSingleNode("statusCode");
			if(statusCodeNode != null){
				marsResultDto.setStatusCode(statusCodeNode.getText());
			}
			
			Node resultMessageNode = rootElement.selectSingleNode("resultMessage");
			
			if(resultMessageNode != null){
				String returMsg = resultMessageNode.getText();
				marsResultDto.setResultMessage(returMsg);
			}
			options.setManageSession(true);   
			options.setProperty(HTTPConstants.REUSE_HTTP_CLIENT,true);   
			serviceClient.cleanupTransport();
		} catch (RemoteException e) {
			LOGGER.error(e);
			marsResultDto.setStatusCode("0");
			marsResultDto.setResultMessage("Call MARS interface error:" + e.getMessage());

		}catch (DocumentException e) {
			LOGGER.error("", e);
			marsResultDto.setStatusCode("0");
			marsResultDto.setResultMessage("MARS returns data error:" + e.getMessage());
			
		}catch (UnsupportedEncodingException e) {
			LOGGER.error("", e);
			marsResultDto.setStatusCode("0");
			marsResultDto.setResultMessage("Package name is null:" + e.getMessage());
		}catch (Exception e) {
			LOGGER.error("", e);
			marsResultDto.setStatusCode("0");
			marsResultDto.setResultMessage("Call MARS interface error:" + e.getMessage());
		}finally{
			try {
				serviceClient.cleanupTransport();
			} catch (AxisFault e) {
				LOGGER.error("", e);
			}
		}
		
		
		marsLog.setSuccessFlag("1".endsWith(marsResultDto.getStatusCode()) ? "success" : "failure" );
		marsLog.setDescp(marsLog.getDescp() + marsResultDto.getResultMessage());
		ThreadPoolUtil.execute(new LogTask(marsLog));
		
		return marsResultDto;
	}

	
	private String getNodeValue(Node rootElement, String select){
		Node node = rootElement.selectSingleNode(select);
		if(node != null){
			return node.getText();
		}
		
		return null;
	}
	
	
	/*
	 * Avoid SSL certificates issue
	 * */
	private static void trustAllHttpsCertificates() throws Exception {
		javax.net.ssl.TrustManager[] trustAllCerts = new javax.net.ssl.TrustManager[1];
		javax.net.ssl.TrustManager tm = new miTM();
		trustAllCerts[0] = tm;
		javax.net.ssl.SSLContext sc = javax.net.ssl.SSLContext
				.getInstance("SSL");
		sc.init(null, trustAllCerts, null);
		javax.net.ssl.HttpsURLConnection.setDefaultSSLSocketFactory(sc
				.getSocketFactory());
	}

	static class miTM implements javax.net.ssl.TrustManager,
			javax.net.ssl.X509TrustManager {
		public java.security.cert.X509Certificate[] getAcceptedIssuers() {
			return null;
		}

		public boolean isServerTrusted(
				java.security.cert.X509Certificate[] certs) {
			return true;
		}

		public boolean isClientTrusted(
				java.security.cert.X509Certificate[] certs) {
			return true;
		}

		public void checkServerTrusted(
				java.security.cert.X509Certificate[] certs, String authType)
				throws java.security.cert.CertificateException {
			return;
		}

		public void checkClientTrusted(
				java.security.cert.X509Certificate[] certs, String authType)
				throws java.security.cert.CertificateException {
			return;
		}
	}

}
